package com.gasstion.controller;

import com.gasstion.dao.SupplierDao;
import com.gasstion.entity.Supplier;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/supplier")
@Scope("prototype")
public class SupplierController {
    @Autowired
    SupplierDao supplierDao;
    @RequestMapping("/query")
    @ResponseBody
    public List<Supplier> query(){

        return supplierDao.query();
    }

    @RequestMapping("/querySearch")
    @ResponseBody
    public List<Supplier> querySearch(String name){
        return supplierDao.querySearch(name);
    }

    @RequestMapping("/save")
    @ResponseBody
    public List<Supplier> querySearch(Supplier supplier){
        supplierDao.save(supplier);
        return supplierDao.querySearch("");
    }
}
